<template>
	<div>
		<Row>
			<Col class="p-1" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="4">
			<Input class="w-100" v-model="searchKey.nickname" placeholder="请输入昵称" />
			</Col>
		</Row>
		<Row>
			<div class="w-100 d-flex justify-content-end align-items-center ">
				<Button class="m-1" type="primary" shape="circle" @click="searchs" icon="ios-search">查询</Button>
			</div>
		</Row>
		<div class="mt-1">
			<Table border :class="'m-1'" :columns="tableInfo.columnInfo" :data="tableInfo.data">
				<template slot-scope="{ row, index }" slot="headimg">
					<div>
						<img style="width: 40px; height: 40px;" :src="row.headimg" />
					</div>
				</template>
				<template slot-scope="{ row, index }" slot="sex">
					<div>
						<span v-if="row.sex == '1'">男</span>
						<span v-if="row.sex == '2'">女</span>
					</div>
				</template>
				<template slot-scope="{ row, index }" slot="action">
					<Button type="primary" size="small" class="mr-2" @click="show(row.clientid)">详细</Button>
				</template>
			</Table>
		</div>
		<div>
			<Page class="text-right mt-3" :page-size="tableInfo.pageSize" @on-change="pageSearch"
				:total="tableInfo.total" />
		</div>
	</div>
</template>
<script>
	export default {
		data() {
			return {
				searchKey: {
					clientid: "",
					openid: "",
					nickname: "",
					sex: "",
					age: "",
					headimg: "",
					from: "",
					tel: "",

				},
				tableInfo: {
					currentPage: 1,
					pageSize: 10,
					total: 0,
					columnInfo: [
						{
							title: "客户编号",
							key: "clientid",
						},
						{
							title: "昵称",
							key: "nickname",
						},
						{
							title: "OPENID",
							key: "openid",
						},
						{
							title: "性别",
							slot: "sex",
						},
						{
							title: "年龄",
							key: "age",
						},
						{
							title: "电话",
							key: "tel",
						},
						{
							title: "操作",
							slot: 'action',
							width: 150
						}
					],
					data: []
				}
			}
		},
		methods: {
			init: function() {
				this.tableInfo.currentPage = 0;
				this.search();
			},
			newUser: function() {
				this.$router.push({
					path: "/client/new"
				})
			},
			show: function(clientid) {
				this.$router.push({
					path: "/client/detail?id=" + clientid
				})
			},
			remove: function(clientid) {
				this.message.confirm({
					title: "删除提示",
					content: "即将删除场馆，确定吗？",
					onOk: () => {
						this.http.delete({
							url: "/client/info",
							param: {
								clientid
							}
						}).then(data => {
							this.search();
						});
					},
					onCancel: () => {
						this.message.info('操作已取消');
					}
				});
			},
			searchs: function() {
				this.tableInfo.currentPage = 1;
				this.search();
			},
			search: function() {
				this.http.get({
					url: "/client/page",
					param: {
						// 传一个当前页
						current: this.tableInfo.currentPage,
						size:this.tableInfo.pageSize,
						
					}
				}).then(data => {
					this.tableInfo.data = data.records;
					this.tableInfo.currentPage = data.current;
					this.tableInfo.total = data.total;
					this.tableInfo.pageSize = data.size;
				});
			},
			pageSearch: function(changedPage) {
				this.tableInfo.currentPage = changedPage;
				this.search();
			}
		},
		created: function() {
			this.init();
		}
	}
</script>

<style>

</style>